import { View, Image, Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, { Component } from 'react';
import * as T from '../types';
import './rightButtons.less';
import actions from '../actions/index';
import { connect } from 'react-redux';
import { store2Props } from '../selectors';
import 'taro-ui/dist/style/components/icon.scss';
import { IPLAND_OSS_HOST } from '../../constant';

type IToolsBoxProps = T.IProps & T.IToolsBoxProps;
//@ts-ignore
@connect<Partial<IToolsBoxProps>, T.IToolsBoxState>(store2Props, actions)
export default class Info extends Component<Partial<IToolsBoxProps>, T.IToolsBoxState> {
  constructor(props: IToolsBoxProps) {
    super(props);
  }

  render() {
    let {
      main: { moPropList, ouPropList },
      actions: { action },
    } = this.props;
    return (
      <View className="buttons">
        {
          moPropList && moPropList.length > 0 &&
          <View className="btn-mo"
            onClick={() => {
              action.commonChange('main.moouTitle', moPropList[0].propVO.propName)
              action.commonChange('main.moouContent', moPropList[0].propVO.propDesc)
              action.commonChange('main.showMoModal', true)
            }}>
            <Image src={moPropList[0].propVO.imgUrl} className="mo" />
            <Text className="timeleft">剩余:{moPropList.length}张</Text>
          </View>}
        {
          ouPropList && ouPropList.length > 0 &&
          < View className="btn-ou"
            onClick={() => {
              action.commonChange('main.moouTitle', ouPropList[0].propVO.propName)
              action.commonChange('main.moouContent', ouPropList[0].propVO.propDesc)
              action.commonChange('main.showOuModal', true)
            }}>
            <Image src={ouPropList[0].propVO.imgUrl} className="ou" />
            <Text className="timeleft">剩余:{ouPropList.length}张</Text>
          </View>
        }
        {/* <View className="btn-shangxin"
          onClick={() => {
            Taro.navigateTo({ url: '/pages/package-I/newActivity/index' })
          }}>
          <Image src={`${IPLAND_OSS_HOST}home/shangxin.png`} className="shangxin" />
        </View> */}
      </View >
    );
  }
}

//create by moon https://github.com/creasy2010/moon
